import {requestParam8080} from "@/Network/requestParam8080";
import {requestBody8080} from "@/Network/requestBody8080";
import type {res, typeSong, typeUser, typeUserLove, typeUserSong} from "@/store/dataType";
import {requestParam5000} from "@/Network/requestParam5000";


// export function testPostRequestParam(data) {
//     let url = "/user-server/user/testRequestParam"
//     return requestForm8082({
//         url: url,
//         method: 'post',
//         data
//     })
// }
//
// export function testPostRequestBody(data) {
//     let url = "/user-server/user/testRequestBody"
//     return requestJson({
//         url: url,
//         method: 'post',
//         data
//     })
// }

export function userLogin(params) {
    let url = "/UserController/login"
    return requestParam8080({
        url: url,
        method: 'post',
        params
    })
}
export function userRegister(data) {
    let url = "/UserController/add"
    return requestBody8080({
        url: url,
        method: 'post',
        data
    })
}
export function findUserById(id) {
    let url = "/UserController/findById/"+id
    return requestBody8080({
        url: url,
        method: 'get'
    }) as Promise<res<typeUser>>
}

// /UserController/addUserLove/{userId}/{songId}
export function addUserLove(userId, songId) {
    let url = "/UserController/addUserLove/"+userId+"/"+songId
    console.log(url)
    return requestBody8080({
        url: url,
        method: 'get'
    }) as Promise<res<typeUserLove>>
}
export function findAllUserSongsByUserOrderByUpdateTimeDesc(userId) {
    let url = "/UserController/findAllUserSongsByUserOrderByUpdateTimeDesc/"+userId
    console.log(url)
    return requestBody8080({
        url: url,
        method: 'get'
    }) as Promise<res<typeSong[]>>
}

export function itemRecommend(userId) {
    let url = "/recommend/item_rec/"+userId
    console.log(url)
    return requestParam5000({
        url: url,
        method: 'get'
    }) as Promise<res<typeSong[]>>
}
export function hotListenCountRecommend() {
    let url = "/recommend/hot_listen_count"
    console.log(url)
    return requestParam5000({
        url: url,
        method: 'get'
    }) as Promise<res<typeSong[]>>
}

export function addUserSong(params) {
    let url = "/UserController/addUserSong"
    console.log(url)
    return requestBody8080({
        url: url,
        method: 'get',
        params
    }) as Promise<res<typeUserSong>>
}

export function updateUserNameById(params) {
    let url = "/UserController/updateUserNameById"
    console.log(url)
    return requestBody8080({
        url: url,
        method: 'get',
        params
    }) as Promise<res<typeUserSong>>
}


export function deleteUserLove(userId, songId) {
    let url = "/UserController/deleteUserLove/"+userId+"/"+songId
    console.log(url)
    return requestBody8080({
        url: url,
        method: 'get'
    }) as Promise<res<typeUserLove>>
}

export function getTaskList(data) {
    let url = "/task-server/task/list"
    return requestJson8084({
        url: url,
        method: 'post',
        data
    })
}

export function updateTask(data) {
    let url = "/task-server/task/update_task"
    return requestJson8084({
        url: url,
        method: 'post',
        data
    })
}

export function getType(params) {
    let url='/task-server/dictionary/get_value'
    return requestForm8084({
        url: url,
        method: 'get',
        params
    })
}

export function deleteTask(params) {
    let url='/task-server/task/delete_task'
    return requestForm8084({
        url: url,
        method: 'get',
        params
    })
}

export function getTaskById(params) {
    let url='/task-server/task/task_by_code'
    return requestForm8084({
        url: url,
        method: 'get',
        params
    })
}

export function getCode() {
    let url='/task-server/task/get_code'
    return requestForm8084({
        url: url,
        method: 'get',
    })
}
// /task-server/task/check_my_list
export function getCheckTaskList(data) {
    let url = "/task-server/task/check_my_list"
    return requestJson8084({
        url: url,
        method: 'post',
        data
    })
}